<div class="nav_top flex d-inline">
  <p class="text-secondary pt-2 float-left nav_title ">
    <% if params[:type] == "wiki" %>
      <a href="/spam2" class="text-dark h4"><i class=" pt-1 pr-2 fa fa-certificate text-success"></i>Spam2/</a><b> <span class="h3">Wiki</span>
    <% elsif params[:action] == "_spam_queue"%>
      <a href="/spam2" class="text-dark h4"><i class=" pt-1 pr-2 fa fa-clock text-success"></i>Spam2/</a><b> <span class="h3">Queue</span>
    <% elsif params[:action] == "_spam_insights"%>
      <a href="/spam2" class="text-dark h4"><i class=" pt-1 pr-2 fa fa-bar-chart text-success"></i>Spam2/</a><b> <span class="h4">Insights</span>
    <% elsif params[:action] == "_spam_revisions"%>
      <a href="/spam2" class="text-dark h4"><i class=" pt-1 pr-2 fa fa-file text-info"></i>Spam2/</a><b> <span class="h4">Revisions</span>
    <% elsif params[:action] == "_spam_comments"%>
      <a href="/spam2" class="text-dark h4"><i class=" pt-1 pr-2 fa fa-comments text-info"></i>Spam2/</a><b> <span class="h4">Comments</span>
    <% elsif params[:action] == "_spam_flags"%>
      <a href="/spam2" class="text-dark h4"><i class=" pt-1 pr-2 fa fa-flag text-info"></i>Spam2/</a><b> <span class="h3">Flags</span>
    <% elsif params[:action] == "_spam_users"%>
      <a href="/spam2" class="text-dark h4"><i class=" pt-1 pr-2 fa fa-user text-primary"></i>Spam2/</a><b> <span class="h3">Users</span>
    <% else %>
      <a href="/spam2" class="text-dark h4"><i class=" pt-1 pr-2 fa fa-check-circle text-success"></i>Spam2/</a><b> <span class="h4">Moderation</span> 
    <% end %> </b>
  </p>
  <div class="dropdown float-right">
    <a class="btn btn-light border border-curve mt-2" type="button" id="dropdownMenuLink" href="#" >
      Menu <i class="fa fa-align-left text-secondary" aria-hidden="true"></i>
    </a>
    <div class="dropdown-menu dropdown-menu-right">
      <h6 class="dropdown-header">Menu | <%= current_user.role%> </h6>
      <a class="dropdown-item <% if params[:action] == "_spam_insights" %> active <% end %>" href="/spam2/insights"><i class="drop fa fa-line-chart text-primary"></i> Insights </a>
      <div class="dropdown-divider"></div>  
      <h6 class="dropdown-header">Spam Moderation</h6>
      <a class="drop_click dropdown-item <% unless  params[:action] =="_spam_comments" ||params[:action] =="_spam_queue" || params[:action] =="_spam_insights"|| params[:action] =="_spam_revisions" || params[:action] =="_spam_flags" || params[:type] == "wiki" || params[:action] == "_spam_users"%> active <% end %>" href="/spam2/filter/all/30"><i class="drop fa fa-address-book text-primary"></i> Moderation</a>
      <a class="wiki_drop_click dropdown-item <% if params[:type] == "wiki" %> active <% end %>" id="wiki_drop" href="/spam2/filter/wiki/30" ><i class="drop fa fa-book text-primary"></i> Wiki</a>
      <a class="drop_click dropdown-item <% if params[:action] == "_spam_queue" %> active <% end %>" href="/spam2/queue/filter/everything" ><i class="drop fa fa-clock text-primary"></i> Queue</a>
      <a class="drop_click dropdown-item <% if params[:action] == "_spam_revisions" %> active <% end %>" href="/spam2/revisions"><i class="drop fa fa-list text-primary"></i> Revision</a>
      <a class="drop_click dropdown-item <% if params[:action] == "_spam_comments" %> active <% end %>" href="/spam2/comments/filter/all/30" ><i class="drop fa fa-comment text-primary"></i> Comments</a>
      <a class="drop_click dropdown-item <% if params[:action] == "_spam_flags" %> active <% end %>"  href="/spam2/flags/filter/all/30" ><i class="drop fa fa-flag text-primary"></i> Flag </a>
      <a class="drop_click dropdown-item  <% if params[:action] == "_spam_users" %> active <% end %>" href="/spam2/users/filter/all/30"><i class="drop fa fa-user text-primary"></i> User moderation</a>
    </div>
  </div>
</div>
<script>
  $(document).on('click', '.drop_click', function(){
    localStorage.setItem('page-select', "30");
    localStorage.setItem('filter', 'all');
  });
  $(document).on('click', '.wiki_drop_click', function(){
    localStorage.setItem('page-select', "30");
    localStorage.setItem('filter', 'wiki');
  });
</script>
<div class="d-flex w-100 " style="overflow-x:auto !important;">
  <a class="btn btn-light border border-curve text-secondary mr-auto font-weight-bold" id="info-btn" data-toggle="collapse" href="#info-div" role="button" aria-expanded="false" aria-controls="info-div">
    Info <i class="fa fa-caret-down text-secondary"></i>
  </a>
  <% if params[:action] != "_spam_comments"&& params[:action] != "_spam_users" && params[:action] != "_spam_insights"%>
    <div class=" d-inline-flex"><a href="/spam2/filter/unmoderated/30"  class="badge badge-pill badge-info mx-2 my-3"><%= Node.where(status: 4).count %> Unmoderated</a></div>
    <div class=" d-inline-flex"><a href="/spam2/flags/filter/all/30" class="badge badge-pill badge-info mx-2 my-3" ><%= Node.where('flag > ?', 0).count %> Flagged</a></div>
  <% end%>
  <% if params[:action] == "_spam_comments" %>
    <div class=" d-inline-flex"><a href="/spam2/comment/filter/unmoderated/30" class="badge badge-pill badge-info mx-2 my-3"><%= Comment.where(status: 4).count %> Unmoderated</a></div>
    <div class=" d-inline-flex"><a href="/spam2/comments/filter/flagged/30"  class="badge badge-pill badge-info  my-3 mx-2" ><%= Comment.where('flag > ?', 0).count %> Flagged</a> </div>
  <% end %>
</div>

<div class="collapse" id="info-div">
  <p class="text-secondary font-italic"><i class="fa fa-certificate text-info" aria-hidden="true"></i> Moderators and admins have the ability to "spam" posts if they include inappropriate content, blatant advertising, or are otherwise problematic. If you're not sure, email at <a href="mailto:moderators@<%= request.host %>" class="badge badge-info badge-pill text-white">moderators@<%= request.host %></a>. If we all work together, we can keep spam to a minimum. Thanks for helping out!</p>
</div>

<nav class="navbar navbar-expand " id="bulk-nav">
  <div class="navbar-expand navbar-nav-scroll d-inline">
    <ul class=" navbar-nav">
      <% if params[:action] != "_spam_users" && params[:action] != "_spam_revisions" && params[:action] != "_spam_insights"%>
        <li class="nav-item pr-4">
          <a class="nav-link btn btn-light border disabled text-dark d-inline-flex border-curve" id="batch-spam" ><i class=" pt-1 pr-2 fa fa-ban text-danger" data-toggle="tooltip" data-placement="top" title="Mark selected items as Spam and ban users"></i>  Spam</a>
        </li>
        <li class="nav-item pr-4">
          <a class="nav-link btn btn-light border disabled text-dark d-inline-flex border-curve"  id="batch-publish" ><i class=" pt-1 pr-2 fa fa-check-circle text-success" data-toggle="tooltip" data-placement="top" title="Mark selected items as Publish and unban users"></i>  Publish</a>
        </li>
        <li class="nav-item pr-4">
          <a class="nav-link btn btn-light border disabled text-dark d-inline-flex border-curve" id="delete-batch"><i class=" pt-1 pr-2 fa fa-trash text-danger" data-toggle="tooltip" data-placement="top" title="Delete selected items"></i> Delete</a>
        </li>
      <% end %>
      
      <% if params[:action] != "_spam_insights" %>
        <li class="nav-item pr-4">
          <a class="nav-link btn btn-light border text-dark d-inline-flex border-curve"  id="all" ><i class=" pt-1 pr-2 fa fa-check text-primary" data-toggle="tooltip" data-placement="top" title="Select all on this page"></i> Select</a>
        </li>
      <% end %>
      

      <% if params[:action] != "_spam_revisions" && params[:action] != "_spam_insights" &&  params[:action] != "_spam_comments" %>
        <li class="nav-item pr-4">
          <a class="nav-link btn btn-light border disabled text-dark d-inline-flex border-curve" id="batch-ban" ><i class=" pt-1 pr-2 fa fa-flag text-danger" data-toggle="tooltip" data-placement="top" title="Ban users"></i> Ban</a>
        </li>
        <li class="nav-item pr-4">
          <a class="nav-link btn btn-light border disabled text-dark d-inline-flex border-curve" id="batch-unban" ><i class=" pt-1 pr-2 fa fa-flag text-success" data-toggle="tooltip" data-placement="top" title="Unban users"></i> Unban</a>
        </li>
        <li class="nav-item pr-4">
          <a href="https://publiclab.org/notes/keshav_sethi0004/08-18-2020/spam-management-dashboard-documentation" target="_blank" class="nav-link btn btn-light border d-inline-flex border-curve text-dark" id="docs-btn" ><i class=" pt-1 pr-2 fa fa-info-circle text-info" data-toggle="tooltip"  data-placement="top" title="Documentation of Spam2"></i> Docs</a>
        </li>
      <% end %>
    </ul>
  </div>
</nav>

<% if params[:action] != "_spam_revisions" && params[:action] != "_spam_insights" && params[:action] != "_spam_queue"%>
  <div class="w-20 d-flex ml-1">
    <a class="btn nav-link text-secondary font-weight-bold">Nodes per page </a>
    <select name="Visible" id="pageselect" class="overflow-hidden mt-1 custom-select custom-select-sm form-control form-control-sm">
      <option value="30">30</option>
      <option value="50">50</option>
      <option value="100">100</option>
      <option value="200">200</option>
      <option value="400">400</option>
      <option value="600">600</option>
      <option value="1000">1000</option>
    </select> 
  </div>
<% end %>

<%= render partial: 'spam2/nodes' if @nodes %>
<%= render partial: 'spam2/revisions' if @revisions %>
<%= render partial: 'spam2/comments' if @comments %>
<%= render partial: 'spam2/insights' if @graph_spammed%>
<%= render partial: 'spam2/queue' if @queue %>
<%= render partial: 'spam2/flags' if @flags %>
<%= render partial: 'spam2/users' if @users %>
